<template>
  <el-card class="web-tool-editor">
    <div slot="header" class="clearfix">
      <span>PDF查看器</span>
    </div>
    <div class="content-btns">
      <el-button size="mini" type="primary" @click="btnClick(0)">自定义组件</el-button>
      <el-button size="mini" type="primary" @click="btnClick(1)">PDF.js</el-button>
    </div>
  </el-card>
</template>

<script lang="ts">
import Config from "@/config/index";
import WPopView from '@/utils/popView'
import { Component, Vue } from "vue-property-decorator";

@Component({})
export default class WebToolPdf extends Vue {
  btnClick(type: string) {
    WPopView.prompt("请输入PDF文件线上地址")
      .then((value: any) => {
        const query = `?file=${value}`;
        if (value) {
          window.open(
            `${
              type ? process.env.VUE_APP_PDF_JS : process.env.VUE_APP_PDF_VUE
            }${query}`
          );
        } else {
          WPopView.msgError("请输入文件地址");
        }
      })
      .catch(() => {});
  }
}
</script>

<style scoped>
</style>
